package com.fengze.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.fengze.business.enums.BusiTypeEnum;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fengze.common.annotation.Log;
import com.fengze.common.core.controller.BaseController;
import com.fengze.common.core.domain.AjaxResult;
import com.fengze.common.enums.BusinessType;
import com.fengze.business.domain.AuditOpinion;
import com.fengze.business.service.IAuditOpinionService;
import com.fengze.common.utils.poi.ExcelUtil;
import com.fengze.common.core.page.TableDataInfo;

/**
 * 审核意见Controller
 * 
 * @author lug
 * @date 2024-12-10
 */
@RestController
@RequestMapping("/business/opinion")
public class AuditOpinionController extends BaseController
{
    @Autowired
    private IAuditOpinionService auditOpinionService;

    /**
     * 查询审核意见列表
     */
    @PreAuthorize("@ss.hasPermi('business:opinion:list')")
    @GetMapping("/list")
    public TableDataInfo list(AuditOpinion auditOpinion)
    {
        startPage();
        List<AuditOpinion> list = auditOpinionService.selectAuditOpinionList(auditOpinion);
        return getDataTable(list);
    }

    /**
     * 导出审核意见列表
     */
    @PreAuthorize("@ss.hasPermi('business:opinion:export')")
    @Log(title = "审核意见", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AuditOpinion auditOpinion)
    {
        List<AuditOpinion> list = auditOpinionService.selectAuditOpinionList(auditOpinion);
        ExcelUtil<AuditOpinion> util = new ExcelUtil<AuditOpinion>(AuditOpinion.class);
        util.exportExcel(response, list, "审核意见数据");
    }

    /**
     * 获取审核意见详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:opinion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(auditOpinionService.selectAuditOpinionById(id));
    }


    /**
     * 获取审核意见详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:opinion:query')")
    @GetMapping(value = "/payment/{busiId}")
    public AjaxResult getOpinion(@PathVariable("busiId") Long busiId)
    {
        return success(auditOpinionService.selectBusi(busiId, BusiTypeEnum.PAYMENT.getType()));
    }



    /**
     * 新增审核意见
     */
    @PreAuthorize("@ss.hasPermi('business:opinion:add')")
    @Log(title = "审核意见", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuditOpinion auditOpinion)
    {
        return toAjax(auditOpinionService.insertAuditOpinion(auditOpinion));
    }

    /**
     * 修改审核意见
     */
    @PreAuthorize("@ss.hasPermi('business:opinion:edit')")
    @Log(title = "审核意见", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AuditOpinion auditOpinion)
    {
        return toAjax(auditOpinionService.updateAuditOpinion(auditOpinion));
    }

    /**
     * 删除审核意见
     */
    @PreAuthorize("@ss.hasPermi('business:opinion:remove')")
    @Log(title = "审核意见", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(auditOpinionService.deleteAuditOpinionByIds(ids));
    }
}
